//
//  LandscapeViewController.m
//  DaiShengInvest
//
//  Created by 张睿 on 2017/7/22.
//  Copyright © 2017年 davinci. All rights reserved.
//

#import "LandscapeViewController.h"
#import "YKLineChart2.h"
#import <SocketRocket.h>
#import "AppDelegate.h"

@interface LandscapeViewController ()<YKLineChartViewDelegate,SRWebSocketDelegate>{
    
    UIDeviceOrientation orientation;
}


//@property (nonatomic, strong)SRWebSocket * webSocket;
@property (nonatomic, strong)SRWebSocket * webSocketNumber;

@property (strong, nonatomic) YKLineChartView2 *klineView;

@property (nonatomic, copy)NSString * buttonString;

@property (nonatomic, strong)NSArray * dataArray;

@property (nonatomic, strong)UIView * bottomView;
@property (nonatomic, strong)UIButton * m1Button;
@property (nonatomic, strong)UIButton * m5Button;
@property (nonatomic, strong)UIButton * m15Button;
@property (nonatomic, strong)UIButton * m30Button;
@property (nonatomic, strong)UIButton * h1Button;
@property (nonatomic, strong)UIButton * h4Button;
@property (nonatomic, strong)UIButton * d1Button;
@property (nonatomic, strong)UIButton * w1Button;
@property (nonatomic, strong)UIButton * mn1Button;

@property (nonatomic, weak)UILabel * nowPriceLabel;
@property (nonatomic, weak)UILabel * higestLabel;
@property (nonatomic, weak)UILabel * higestValueLabel;
@property (nonatomic, weak)UILabel * lowestLabel;
@property (nonatomic, weak)UILabel * lowestValueLabel;
@property (nonatomic, weak)UILabel * yestdayLabel;
@property (nonatomic, weak)UILabel * yestdayValueLabel;
@property (nonatomic, weak)UILabel * todayLabel;
@property (nonatomic, weak)UILabel * todayValueLabel;

@property (nonatomic, strong)NSArray * fiveArray;
@property (nonatomic, strong)NSArray * threeArray;
@property (nonatomic, strong)NSArray * twoArray;

@end

@implementation LandscapeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
//    self.dataArray = @[@"1分钟",@"5分钟",@"15分钟",@"30分钟",@"1小时",@"4小时",@"1天",@"1周",@"1月"];
    self.view.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
    self.view.backgroundColor = [UIColor blackColor];
    
    self.fiveArray = @[@"EURUSDapp",@"NZDUSDapp",@"EURCADapp",@"USDCADapp",@"EURNZDapp",@"AUDNZDapp",@"AUDUSDapp",@"AUDCADapp",@"GBPCHFapp",@"EURAUDapp",@"EURGBPapp",@"CADCHFapp",@"GBPAUDapp",@"EURCHFapp",@"USDCHFapp",@"GBPCADapp",@"GBPNZDapp",@"AUDCHFapp",@"GBPUSDapp"];
    self.threeArray = @[@"XAGUSDapp",@"GBPJPYapp",@"AUDJPYapp",@"USDJPYapp",@"EURJPYapp",@"CADJPYapp",@"NZDJPYapp"];
    self.twoArray = @[@"XAUUSDapp"];
    
    self.buttonString = @"m1";
    
    [self loadData];
    [self loadKlineViewData];
//    [self setupUI];
    
    [self interfaceOrientation:UIInterfaceOrientationLandscapeLeft];
}


//强制转屏
- (void)interfaceOrientation:(UIInterfaceOrientation)orientation
{
    if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
        SEL selector  = NSSelectorFromString(@"setOrientation:");
        NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]];
        [invocation setSelector:selector];
        [invocation setTarget:[UIDevice currentDevice]];
        int val = orientation;
        // 从2开始是因为0 1 两个参数已经被selector和target占用
        [invocation setArgument:&val atIndex:2];
        [invocation invoke];
    }
}


- (void)loadKlineViewData{
    
//    static int ma5 = 0;
//    static int ma10 = 0;
//    static int ma20 = 0;
    
    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    
    NSString * startStr;
    
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    
    [formatter setDateStyle:NSDateFormatterMediumStyle];
    
    [formatter setTimeStyle:NSDateFormatterShortStyle];
    
    [formatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"]; // ----------设置你想要的格式,hh与HH的区别:分别表示12小时制,24小时制
    
    //设置时区,这个对于时间的处理有时很重要
    
    NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];
    
    [formatter setTimeZone:timeZone];
    
    NSDate *datenow = [NSDate date];//现在时间
    
    //时间转时间戳的方法:
    
    NSInteger timeSp = [[NSNumber numberWithDouble:[datenow timeIntervalSince1970]] integerValue];
    
    if ([self.buttonString isEqualToString:@"m1"]) {
        
        NSString * isSunday = [self weekdayStringFromDate:datenow];
        
        NSInteger startTime = 0;
        
        if ([isSunday isEqualToString:@"Sunday"]) {
            startTime = timeSp - 2 * 24 * 3600;
        }else{
            startTime = timeSp - 1 * 24 * 3600;
        }
        
        
        
        NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:startTime];
        
        NSString *confromTimespStr = [formatter stringFromDate:confromTimesp];
        
        
        NSArray *array = [confromTimespStr componentsSeparatedByString:@" "]; //从字符A中分隔成2个元素的数组
        
        startStr = [NSString stringWithFormat:@"%@T%@Z",array.firstObject,array.lastObject];
        NSLog(@"==%@",startStr);
    }else if ([self.buttonString isEqualToString:@"m5"]){
        
        NSInteger startTime = timeSp - 5 * 24 * 3600;
        
        NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:startTime];
        
        NSString *confromTimespStr = [formatter stringFromDate:confromTimesp];
        
        
        NSArray *array = [confromTimespStr componentsSeparatedByString:@" "]; //从字符A中分隔成2个元素的数组
        
        startStr = [NSString stringWithFormat:@"%@T%@Z",array.firstObject,array.lastObject];
        //        NSLog(@"==%@",startStr);
    }else if ([self.buttonString isEqualToString:@"m15"]){
        
        NSInteger startTime = timeSp - 15 * 24 * 3600;
        
        NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:startTime];
        
        NSString *confromTimespStr = [formatter stringFromDate:confromTimesp];
        
        
        NSArray *array = [confromTimespStr componentsSeparatedByString:@" "]; //从字符A中分隔成2个元素的数组
        
        startStr = [NSString stringWithFormat:@"%@T%@Z",array.firstObject,array.lastObject];
        //        NSLog(@"==%@",startStr);
    }else if ([self.buttonString isEqualToString:@"m30"]){
        
        NSInteger startTime = timeSp - 30 * 24 * 3600;
        
        NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:startTime];
        
        NSString *confromTimespStr = [formatter stringFromDate:confromTimesp];
        
        
        NSArray *array = [confromTimespStr componentsSeparatedByString:@" "]; //从字符A中分隔成2个元素的数组
        
        startStr = [NSString stringWithFormat:@"%@T%@Z",array.firstObject,array.lastObject];
        //        NSLog(@"==%@",startStr);
    }else if ([self.buttonString isEqualToString:@"h1"]){
        
        NSInteger startTime = timeSp - 60 * 24 * 3600;
        
        NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:startTime];
        
        NSString *confromTimespStr = [formatter stringFromDate:confromTimesp];
        
        
        NSArray *array = [confromTimespStr componentsSeparatedByString:@" "]; //从字符A中分隔成2个元素的数组
        
        startStr = [NSString stringWithFormat:@"%@T%@Z",array.firstObject,array.lastObject];
        //        NSLog(@"==%@",startStr);
    }else if ([self.buttonString isEqualToString:@"h4"]){
        
        NSInteger startTime = timeSp - 240 * 24 * 3600;
        
        NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:startTime];
        
        NSString *confromTimespStr = [formatter stringFromDate:confromTimesp];
        
        
        NSArray *array = [confromTimespStr componentsSeparatedByString:@" "]; //从字符A中分隔成2个元素的数组
        
        startStr = [NSString stringWithFormat:@"%@T%@Z",array.firstObject,array.lastObject];
        NSLog(@"==%@",startStr);
    }else if ([self.buttonString isEqualToString:@"d1"]){
        
        NSInteger startTime = timeSp - 1440 * 24 * 3600;
        
        NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:startTime];
        
        NSString *confromTimespStr = [formatter stringFromDate:confromTimesp];
        
        
        NSArray *array = [confromTimespStr componentsSeparatedByString:@" "]; //从字符A中分隔成2个元素的数组
        
        startStr = [NSString stringWithFormat:@"%@T%@Z",array.firstObject,array.lastObject];
        NSLog(@"==%@",startStr);
    }else if ([self.buttonString isEqualToString:@"w1"]){
        
        NSInteger startTime = timeSp - 10080 * 24 * 3600;
        
        NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:startTime];
        
        NSString *confromTimespStr = [formatter stringFromDate:confromTimesp];
        
        
        NSArray *array = [confromTimespStr componentsSeparatedByString:@" "]; //从字符A中分隔成2个元素的数组
        
        startStr = [NSString stringWithFormat:@"%@T%@Z",array.firstObject,array.lastObject];
//        NSLog(@"==%@",startStr);
    }else{
        
        NSInteger startTime = timeSp * 0;
        
        NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:startTime];
        
        NSString *confromTimespStr = [formatter stringFromDate:confromTimesp];
        
        
        NSArray *array = [confromTimespStr componentsSeparatedByString:@" "]; //从字符A中分隔成2个元素的数组
        
        startStr = [NSString stringWithFormat:@"%@T%@Z",array.firstObject,array.lastObject];
//        NSLog(@"==%@",startStr);
    }
    
    NSDictionary * parameters = @{@"period":self.buttonString,@"symbol":self.nameString,@"startTime":startStr};
    
    [[NetworkTool sharedTools] POST:@"symbols/charts" parameters:parameters progress:nil success:^(NSURLSessionDataTask * _Nonnull task, NSDictionary *  _Nullable responseObject) {
        
        [MBProgressHUD hideHUDForView:self.view animated:YES];
        
//        NSLog(@"==%@",responseObject);
        
        NSDictionary * dict = responseObject[@"param"];
        NSArray * sourceArray = dict[@"list"];
        NSArray * openPriceAndClosePrice = dict[@"openPriceAndClosePrice"];
        NSDictionary * yesterday = openPriceAndClosePrice.firstObject;
        NSDictionary * today = openPriceAndClosePrice.lastObject;
        
        //    NSString * path =[[NSBundle mainBundle]pathForResource:@"data.plist" ofType:nil];
        //    NSArray * sourceArray = [[NSDictionary dictionaryWithContentsOfFile:path] objectForKey:@"data"];
        NSMutableArray * array = [NSMutableArray array];
//        NSMutableArray * ma5Array = [NSMutableArray array];
//        NSMutableArray * ma10Array = [NSMutableArray array];
//        NSMutableArray * ma20Array = [NSMutableArray array];
        NSString * countype;
        BOOL isFivebool = [self.fiveArray containsObject: self.nameString];
        BOOL isThreebool = [self.threeArray containsObject: self.nameString];
        BOOL isTwobool = [self.twoArray containsObject: self.nameString];
        
        if (isFivebool) {
            countype = @"five";
        }
        
        if (isThreebool) {
            countype = @"three";
        }
        
        if (isTwobool) {
            countype = @"two";
        }
        
        for (NSDictionary * dic in sourceArray) {
            
//            ma5 ++;//  = count + 1;
//            ma10 ++;
//            ma20 ++;
            
            
            YKLineEntity2 * entity = [[YKLineEntity2 alloc]init];
            entity.high = [dic[@"high"] doubleValue] * 10000;
            entity.open = [dic[@"open"] doubleValue] * 10000;
            
            entity.low = [dic[@"low"] doubleValue] * 10000;
            
            double close =  [dic[@"close"] doubleValue] * 10000;
            
            entity.close = close;
            
            NSString *string = [NSString stringWithFormat:@"%@",dic[@"timestamp"]];//model.modifyTime;
            NSTimeInterval second = string.longLongValue;
            
            // 时间戳 -> NSDate *
            NSDateFormatter *matter = [[NSDateFormatter alloc]init];
            matter.dateFormat =@"MM-dd HH:mm";
            NSDate *date = [NSDate dateWithTimeIntervalSince1970:second];
            NSString*timeStr = [matter stringFromDate:date];
            //        NSLog(@"%@", date);
            
            //        self.timeLabel.text = [NSString stringWithFormat:@"%@",date];
            
            entity.date = [NSString stringWithFormat:@"%@", timeStr];//dic[@"date"];
            
            //存入
//            NSNumber *number = [NSNumber numberWithDouble:close];
//            [ma5Array addObject:number];
//            //取出
////            [[ma5Array objectAtIndex:0] floatValue];
//            
//            //存入
//            [ma10Array addObject:number];
//            
//            //存入
//            [ma20Array addObject:number];
//            
//            if (ma5 == 5) {
//                
//                NSNumber *avg = [ma5Array valueForKeyPath:@"@sum.self"];
//                
//                double  close = [avg doubleValue];
//                
//                NSLog(@"ma5==%f",close);
//                
//                entity.ma5 = close / 5;
//                
//                [ma5Array removeAllObjects];
//                ma5 = 0;
//            }else{
//                
//                entity.ma5 = close;
//            }
//            
//            if (ma10 == 10) {
//                
//                NSNumber *avg = [ma10Array valueForKeyPath:@"@sum.self"];
//                
//                double  close = [avg doubleValue];
//                
//                NSLog(@"ma10==%f",close);
//                
//                entity.ma10 = close / 10;
//                
//                [ma10Array removeAllObjects];
//                ma10 = 0;
//            }else{
//                
//                entity.ma10 = close;
//            }
//            
//            if (ma20 == 20) {
//                
//                NSNumber *avg = [ma20Array valueForKeyPath:@"@sum.self"];
//                
//                double  close = [avg doubleValue];
//                
//                NSLog(@"ma20==%f",close);
//                
//                entity.ma20 = close / 20;
//                
//                [ma20Array removeAllObjects];
//                ma20 = 0;
//            }else{
//                
//                entity.ma20 = close;
//            }
            
//            entity.ma5 = 0;//[dic[@"avg5"] doubleValue];
//            entity.ma10 = 0;//[dic[@"avg10"] doubleValue];
//            entity.ma20 = 0;//[dic[@"avg20"] doubleValue];
            entity.volume = [dic[@"volume"] doubleValue] * 10000;//[dic[@"total_volume_trade"] doubleValue];
            [array addObject:entity];
            //YTimeLineEntity * entity = [[YTimeLineEntity alloc]init];
        }
        //    [array addObjectsFromArray:array];
        
        
        
        YKLineDataSet2 * dataset = [[YKLineDataSet2 alloc]init];
        dataset.data = array;
        dataset.highlightLineColor = [UIColor whiteColor];//[UIColor colorWithRed:60/255.0 green:76/255.0 blue:109/255.0 alpha:1.0];
        dataset.highlightLineWidth = 0.7;
        dataset.candleRiseColor = [UIColor colorWithRed:233/255.0 green:47/255.0 blue:68/255.0 alpha:1.0];
        dataset.candleFallColor = [UIColor colorWithRed:33/255.0 green:179/255.0 blue:77/255.0 alpha:1.0];
        dataset.avgLineWidth = 1.f;
        dataset.avgMA10Color = [UIColor colorWithRed:252/255.0 green:85/255.0 blue:198/255.0 alpha:1.0];
        dataset.avgMA5Color = [UIColor colorWithRed:67/255.0 green:85/255.0 blue:109/255.0 alpha:1.0];
        dataset.avgMA20Color = [UIColor colorWithRed:216/255.0 green:192/255.0 blue:44/255.0 alpha:1.0];
        dataset.candleTopBottmLineWidth = 1;
        
        self.klineView = [[YKLineChartView2 alloc] initWithFrame:CGRectMake(0, 30 * SCREENH6, SCREEN_WIDTH, SCREENH_HEIGHT - 30 * SCREENH6)];
        [self.view addSubview:self.klineView];
        
        [self.klineView setupChartOffsetWithLeft:50 top:10 right:10 bottom:-60];
        self.klineView.gridBackgroundColor = [UIColor blackColor];
        self.klineView.borderColor = [UIColor colorWithRed:203/255.0 green:215/255.0 blue:224/255.0 alpha:1.0];
        self.klineView.borderWidth = .5;
        self.klineView.candleWidth = 8;
        self.klineView.candleMaxWidth = 30;
        self.klineView.candleMinWidth = 7;
        self.klineView.uperChartHeightScale = 0.7;
        self.klineView.xAxisHeitht = 25;
        self.klineView.delegate = self;
        self.klineView.highlightLineShowEnabled = YES;
        self.klineView.zoomEnabled = YES;
        self.klineView.scrollEnabled = YES;
        self.klineView.type = @"land";
        self.klineView.countType = countype;
//        self.klineView.rightYAxisDrawEnabled = YES;
//        self.klineView.leftYAxisIsInChart = NO;
        [self.klineView setupData:dataset];
        
//        if ([self.changeButton isEqualToString:@"1"]) {
            [self setupUI];
//        }
        
        self.bottomView.hidden = NO;
        
        [self.view bringSubviewToFront:self.bottomView];
        
        UIButton * presentButton = [[UIButton alloc] initWithFrame:CGRectMake(10 * SCREENH6, 10 * SCREENH6, 20 * SCREENH6, 20 * SCREENH6)];
        
        [presentButton setBackgroundColor:[UIColor blackColor]];
        //    [presentButton setTitle:@"did" forState:UIControlStateNormal];
        [presentButton setImage:[UIImage imageNamed:@"横屏转竖屏"] forState:UIControlStateNormal];
        [presentButton addTarget:self action:@selector(dismissModalViewControllerAnimated:) forControlEvents:UIControlEventTouchUpInside];
        
        [self.view addSubview:presentButton];
        
        UILabel * nowPriceLabel = [UILabel new];
        
        nowPriceLabel.textColor = [UIColor whiteColor];
        nowPriceLabel.font = [UIFont systemFontOfSize:20 * SCREENH6];
        nowPriceLabel.text = @"----";
        
        self.nowPriceLabel = nowPriceLabel;
        
        [self.klineView addSubview:self.nowPriceLabel];
        
        [self.nowPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX. mas_equalTo(self.klineView);
            make.centerY.mas_equalTo(presentButton);
        }];
        
        UILabel * higestLabel = [UILabel new];
        
        higestLabel.textColor = ColorWithRGB(0x8d8d8d);
//        higestLabel.backgroundColor = [UIColor redColor];
        higestLabel.font = [UIFont systemFontOfSize:7 * SCREENH6];
        higestLabel.text = @"最高:";
        
        self.higestLabel = higestLabel;
        
        [self.klineView addSubview:self.higestLabel];
        
        [self.higestLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.mas_equalTo(self.nowPriceLabel.mas_trailing).offset(20 * SCREENH6);
            make.top.mas_equalTo(presentButton);
        }];
        
        UILabel * higestValueLabel = [UILabel new];
        
        higestValueLabel.textColor = ColorWithRGB(0x8d8d8d);
        higestValueLabel.font = [UIFont systemFontOfSize:7 * SCREENH6];
        higestValueLabel.text = @"----";
        
        self.higestValueLabel = higestValueLabel;
        
        [self.klineView addSubview:self.higestValueLabel];
        
        [self.higestValueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading. mas_equalTo(self.higestLabel.mas_trailing).offset(5 * SCREENH6);
            make.centerY.mas_equalTo(self.higestLabel);
        }];
        
        
        UILabel * lowestLabel = [UILabel new];
        
        lowestLabel.textColor = ColorWithRGB(0x8d8d8d);
        lowestLabel.font = [UIFont systemFontOfSize:7 * SCREENH6];
        lowestLabel.text = @"最低:";
        
        self.lowestLabel = lowestLabel;
        
        [self.klineView addSubview:self.lowestLabel];
        
        [self.lowestLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading. mas_equalTo(self.higestLabel);
            make.top.mas_equalTo(self.higestLabel.mas_bottom).offset(3 * SCREENH6);
        }];
        
        UILabel * lowestValueLabel = [UILabel new];
        
        lowestValueLabel.textColor = ColorWithRGB(0x8d8d8d);
        lowestValueLabel.font = [UIFont systemFontOfSize:7 * SCREENH6];
        lowestValueLabel.text = @"----";
        
        self.lowestValueLabel = lowestValueLabel;
        
        [self.klineView addSubview:self.lowestValueLabel];
        
        [self.lowestValueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading. mas_equalTo(self.higestValueLabel);
            make.centerY.mas_equalTo(self.lowestLabel);
        }];
        
        
        UILabel * yestdayLabel = [UILabel new];
        
        yestdayLabel.textColor = ColorWithRGB(0x8d8d8d);
        //        higestLabel.backgroundColor = [UIColor redColor];
        yestdayLabel.font = [UIFont systemFontOfSize:7 * SCREENH6];
        yestdayLabel.text = @"今日开盘:";
        
        self.yestdayLabel = yestdayLabel;
        
        [self.klineView addSubview:self.yestdayLabel];
        
        [self.yestdayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.mas_equalTo(self.higestValueLabel.mas_trailing).offset(10 * SCREENH6);
            make.centerY.mas_equalTo(self.higestValueLabel);
        }];
        
        UILabel * yestdayValueLabel = [UILabel new];
        
        yestdayValueLabel.textColor = ColorWithRGB(0x8d8d8d);
        yestdayValueLabel.font = [UIFont systemFontOfSize:7 * SCREENH6];
        float todayF = [today[@"open"] floatValue];
        
        if ([countype isEqualToString:@"five"]) {
            
           yestdayValueLabel.text = [NSString stringWithFormat:@"%.5f",todayF];
        }else if ([countype isEqualToString:@"three"]){
            
            yestdayValueLabel.text = [NSString stringWithFormat:@"%.3f",todayF];
        }else{
            yestdayValueLabel.text = [NSString stringWithFormat:@"%.2f",todayF];
        }
        
        
        self.yestdayValueLabel = yestdayValueLabel;
        
        [self.klineView addSubview:self.yestdayValueLabel];
        
        [self.yestdayValueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.mas_equalTo(self.yestdayLabel.mas_trailing).offset(5 * SCREENH6);
            make.centerY.mas_equalTo(self.yestdayLabel);
        }];
        
        
        UILabel * todayLabel = [UILabel new];
        
        todayLabel.textColor = ColorWithRGB(0x8d8d8d);
        todayLabel.font = [UIFont systemFontOfSize:7 * SCREENH6];
        todayLabel.text = @"昨日收盘:";
        
        self.todayLabel = todayLabel;
        
        [self.klineView addSubview:self.todayLabel];
        
        [self.todayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading. mas_equalTo(self.yestdayLabel);
            make.centerY.mas_equalTo(self.lowestValueLabel);
        }];
        
        UILabel * todayValueLabel = [UILabel new];
        
        todayValueLabel.textColor = ColorWithRGB(0x8d8d8d);
        todayValueLabel.font = [UIFont systemFontOfSize:7 * SCREENH6];
        float yesF = [today[@"close"] floatValue];
        
        if ([countype isEqualToString:@"five"]) {
            
            todayValueLabel.text = [NSString stringWithFormat:@"%.5f",yesF];
        }else if ([countype isEqualToString:@"three"]){
            
            todayValueLabel.text = [NSString stringWithFormat:@"%.3f",yesF];
        }else{
            todayValueLabel.text = [NSString stringWithFormat:@"%.2f",yesF];
        }
        
        self.todayValueLabel = todayValueLabel;
        
        [self.klineView addSubview:self.todayValueLabel];
        
        [self.todayValueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.mas_equalTo(self.yestdayValueLabel);
            make.centerY.mas_equalTo(self.todayLabel);
        }];
        
        
        UILabel * titleLabel = [UILabel new];
        
        titleLabel.textColor = [UIColor whiteColor];
        titleLabel.font = [UIFont systemFontOfSize:8 * SCREENH6];
        titleLabel.text = self.titleString;
        
        [self.klineView addSubview:titleLabel];
        
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.mas_equalTo(presentButton.mas_trailing).offset(10 * SCREENH6);
            make.centerY.mas_equalTo(presentButton);
        }];
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
        NSLog(@"%@",error);
    }];
    
}


- (void)deviceOrientationDidChange{
    
    [self.bottomView mas_updateConstraints:^(MASConstraintMaker *make) {
//        make.top.mas_equalTo(self.view).offset(SCREENH_HEIGHT - 17 * SCREENH6);
//        make.leading.trailing.mas_equalTo(self.view);
//        make.bottom.mas_equalTo(self.view);
        
        make.height.mas_equalTo(20 * SCREENH6);
        make.leading.mas_equalTo(self.view);
        make.top.mas_equalTo(self.view).offset(SCREENH_HEIGHT - 20 * SCREENH6);
        make.width.mas_equalTo(SCREEN_WIDTH);
    }];
}


- (void)setupUI{
    
    self.bottomView = [[UIView alloc] init];
    
    self.bottomView.backgroundColor = [UIColor blackColor];
    self.bottomView.userInteractionEnabled = YES;
    self.bottomView.hidden = YES;
    
    [self.klineView addSubview:self.bottomView];
    
//    [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.mas_equalTo(self.klineView.mas_trailing);
//        make.bottom.mas_equalTo(self.view);
//        make.height.mas_equalTo(25 * SCREENH6);
//        make.width.mas_equalTo(SCREENH_HEIGHT);
//    }];
    [self.bottomView mas_updateConstraints:^(MASConstraintMaker *make) {
//        make.leading.mas_equalTo(self.view).offset(SCREENH_HEIGHT - 25);
//        make.top.bottom.mas_equalTo(self.view);
//        make.width.mas_equalTo(25 * SCREENH6);
        make.top.mas_equalTo(self.klineView.mas_bottom).offset(-40);
        make.leading.mas_equalTo(self.klineView);
        make.height.mas_equalTo(25 * SCREENH6);
        make.width.mas_equalTo(self.klineView);
    }];
    
    float y = 5 * SCREENH6;
    float x = 10 * SCREENH6;
    float icoW = 25 * SCREENH6;//40;
    //    float icoH = 10 * SCREENH6;//65;
    float spliW = 10 * SCREENH6;
    
    
    
    //    y = topH+splitH;
    
    //    for (int i = 0; i < 8; i++) {
    //
    //        UIButton * button = [[UIButton alloc] initWithFrame:CGRectMake(x, y, icoW, icoH)];
    //
    //        button.tag = 990 +i;
    //
    //        [button setTitle:self.dataArray[i] forState:UIControlStateNormal];
    //        button.titleLabel.font = [UIFont systemFontOfSize:7 * SCREENH6];//0x8d8d8d
    //        [button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    ////        [button setTitleColor:ColorWithRGB(0xffffff) forState:UIControlStateSelected];
    //        [button addTarget:self action:@selector(UesrClicked:) forControlEvents:UIControlEventTouchUpInside];
    //        [self.view addSubview:button];
    //
    //        x += icoW+spliW;
    //    }
    
    self.m1Button = [[UIButton alloc] initWithFrame:CGRectMake(x, y, icoW, spliW)];
    
    
    self.m1Button.selected = YES;
    [self.m1Button setTitle:@"1分钟" forState:UIControlStateNormal];
    self.m1Button.titleLabel.font = [UIFont systemFontOfSize:7 * SCREENH6];
    [self.m1Button setTitleColor:ColorWithRGB(0x8d8d8d) forState:UIControlStateNormal];
    [self.m1Button setTitleColor:ColorWithRGB(0xffffff) forState:UIControlStateSelected];
    [self.m1Button addTarget:self action:@selector(UesrClicked:) forControlEvents:UIControlEventTouchUpInside];
    [self.bottomView addSubview:self.m1Button];
    
    x += icoW+spliW;
    
    self.m5Button = [[UIButton alloc] initWithFrame:CGRectMake(x, y, icoW, spliW)];
    
    self.m5Button.selected = NO;
    [self.m5Button setTitle:@"5分钟" forState:UIControlStateNormal];
    self.m5Button.titleLabel.font = [UIFont systemFontOfSize:7 * SCREENH6];
    [self.m5Button setTitleColor:ColorWithRGB(0x8d8d8d) forState:UIControlStateNormal];
    [self.m5Button setTitleColor:ColorWithRGB(0xffffff) forState:UIControlStateSelected];
    [self.m5Button addTarget:self action:@selector(UesrClicked:) forControlEvents:UIControlEventTouchUpInside];
    [self.bottomView addSubview:self.m5Button];
    
    x += icoW+spliW;
    
    self.m15Button = [[UIButton alloc] initWithFrame:CGRectMake(x, y, icoW, spliW)];
    
    self.m15Button.selected = NO;
    [self.m15Button setTitle:@"15分钟" forState:UIControlStateNormal];
    self.m15Button.titleLabel.font = [UIFont systemFontOfSize:7 * SCREENH6];
    [self.m15Button setTitleColor:ColorWithRGB(0x8d8d8d) forState:UIControlStateNormal];
    [self.m15Button setTitleColor:ColorWithRGB(0xffffff) forState:UIControlStateSelected];
    [self.m15Button addTarget:self action:@selector(UesrClicked:) forControlEvents:UIControlEventTouchUpInside];
    [self.bottomView addSubview:self.m15Button];
    
    x += icoW+spliW;
    
    self.m30Button = [[UIButton alloc] initWithFrame:CGRectMake(x, y, icoW, spliW)];
    
    self.m30Button.selected = NO;
    [self.m30Button setTitle:@"30分钟" forState:UIControlStateNormal];
    self.m30Button.titleLabel.font = [UIFont systemFontOfSize:7 * SCREENH6];
    [self.m30Button setTitleColor:ColorWithRGB(0x8d8d8d) forState:UIControlStateNormal];
    [self.m30Button setTitleColor:ColorWithRGB(0xffffff) forState:UIControlStateSelected];
    [self.m30Button addTarget:self action:@selector(UesrClicked:) forControlEvents:UIControlEventTouchUpInside];
    [self.bottomView addSubview:self.m30Button];
    
    
    x += icoW+spliW;
    
    self.h1Button = [[UIButton alloc] initWithFrame:CGRectMake(x, y, icoW, spliW)];
    
    self.h1Button.selected = NO;
    [self.h1Button setTitle:@"1小时" forState:UIControlStateNormal];
    self.h1Button.titleLabel.font = [UIFont systemFontOfSize:7 * SCREENH6];
    [self.h1Button setTitleColor:ColorWithRGB(0x8d8d8d) forState:UIControlStateNormal];
    [self.h1Button setTitleColor:ColorWithRGB(0xffffff) forState:UIControlStateSelected];
    [self.h1Button addTarget:self action:@selector(UesrClicked:) forControlEvents:UIControlEventTouchUpInside];
    [self.bottomView addSubview:self.h1Button];
    
    x += icoW+spliW;
    
    self.h4Button = [[UIButton alloc] initWithFrame:CGRectMake(x, y, icoW, spliW)];
    
    self.h4Button.selected = NO;
    [self.h4Button setTitle:@"4小时" forState:UIControlStateNormal];
    self.h4Button.titleLabel.font = [UIFont systemFontOfSize:7 * SCREENH6];
    [self.h4Button setTitleColor:ColorWithRGB(0x8d8d8d) forState:UIControlStateNormal];
    [self.h4Button setTitleColor:ColorWithRGB(0xffffff) forState:UIControlStateSelected];
    [self.h4Button addTarget:self action:@selector(UesrClicked:) forControlEvents:UIControlEventTouchUpInside];
    [self.bottomView addSubview:self.h4Button];
    
    
    x += icoW+spliW;
    
    self.d1Button = [[UIButton alloc] initWithFrame:CGRectMake(x, y, icoW, spliW)];
    
    self.d1Button.selected = NO;
    [self.d1Button setTitle:@"1天" forState:UIControlStateNormal];
    self.d1Button.titleLabel.font = [UIFont systemFontOfSize:7 * SCREENH6];
    [self.d1Button setTitleColor:ColorWithRGB(0x8d8d8d) forState:UIControlStateNormal];
    [self.d1Button setTitleColor:ColorWithRGB(0xffffff) forState:UIControlStateSelected];
    [self.d1Button addTarget:self action:@selector(UesrClicked:) forControlEvents:UIControlEventTouchUpInside];
    [self.bottomView addSubview:self.d1Button];
    
    x += icoW+spliW;
    
    self.w1Button = [[UIButton alloc] initWithFrame:CGRectMake(x, y, icoW, spliW)];
    
    self.w1Button.selected = NO;
    [self.w1Button setTitle:@"1周" forState:UIControlStateNormal];
    self.w1Button.titleLabel.font = [UIFont systemFontOfSize:7 * SCREENH6];
    [self.w1Button setTitleColor:ColorWithRGB(0x8d8d8d) forState:UIControlStateNormal];
    [self.w1Button setTitleColor:ColorWithRGB(0xffffff) forState:UIControlStateSelected];
    [self.w1Button addTarget:self action:@selector(UesrClicked:) forControlEvents:UIControlEventTouchUpInside];
    [self.bottomView addSubview:self.w1Button];
    
    x += icoW+spliW;
    
    self.mn1Button = [[UIButton alloc] initWithFrame:CGRectMake(x, y, icoW, spliW)];
    
    self.mn1Button.selected = NO;
    [self.mn1Button setTitle:@"1月" forState:UIControlStateNormal];
    self.mn1Button.titleLabel.font = [UIFont systemFontOfSize:7 * SCREENH6];
    [self.mn1Button setTitleColor:ColorWithRGB(0x8d8d8d) forState:UIControlStateNormal];
    [self.mn1Button setTitleColor:ColorWithRGB(0xffffff) forState:UIControlStateSelected];
    [self.mn1Button addTarget:self action:@selector(UesrClicked:) forControlEvents:UIControlEventTouchUpInside];
    [self.bottomView addSubview:self.mn1Button];
    
    
    if ([self.buttonString isEqualToString:@"m1"]) {
        
        self.m1Button.selected = YES;
        
        self.m5Button.selected = NO;
        self.m15Button.selected = NO;
        self.m30Button.selected = NO;
        self.h1Button.selected = NO;
        self.h4Button.selected = NO;
        self.d1Button.selected = NO;
        self.w1Button.selected = NO;
        self.mn1Button.selected = NO;
    }else if([self.buttonString isEqualToString:@"m5"]){
        
        self.m5Button.selected = YES;
        
        self.m1Button.selected = NO;
        self.m15Button.selected = NO;
        self.m30Button.selected = NO;
        self.h1Button.selected = NO;
        self.h4Button.selected = NO;
        self.d1Button.selected = NO;
        self.w1Button.selected = NO;
        self.mn1Button.selected = NO;
    }else if ([self.buttonString isEqualToString:@"m15"]){
        
        self.m15Button.selected = YES;
        
        self.m1Button.selected = NO;
        self.m5Button.selected = NO;
        self.m30Button.selected = NO;
        self.h1Button.selected = NO;
        self.h4Button.selected = NO;
        self.d1Button.selected = NO;
        self.w1Button.selected = NO;
        self.mn1Button.selected = NO;

    }else if ([self.buttonString isEqualToString:@"m30"]){
        
        self.m30Button.selected = YES;
        
        self.m1Button.selected = NO;
        self.m5Button.selected = NO;
        self.m15Button.selected = NO;
        self.h1Button.selected = NO;
        self.h4Button.selected = NO;
        self.d1Button.selected = NO;
        self.w1Button.selected = NO;
        self.mn1Button.selected = NO;
        
    }else if ([self.buttonString isEqualToString:@"h1"]){
        
        self.h1Button.selected = YES;
        
        self.m1Button.selected = NO;
        self.m5Button.selected = NO;
        self.m15Button.selected = NO;
        self.m30Button.selected = NO;
        self.h4Button.selected = NO;
        self.d1Button.selected = NO;
        self.w1Button.selected = NO;
        self.mn1Button.selected = NO;
    }else if ([self.buttonString isEqualToString:@"h4"]){
        
        self.h4Button.selected = YES;
        
        self.m1Button.selected = NO;
        self.m5Button.selected = NO;
        self.m15Button.selected = NO;
        self.m30Button.selected = NO;
        self.h1Button.selected = NO;
        self.d1Button.selected = NO;
        self.w1Button.selected = NO;
        self.mn1Button.selected = NO;
        
    }else if ([self.buttonString isEqualToString:@"d1"]){
        
        self.d1Button.selected = YES;
        
        self.m1Button.selected = NO;
        self.m5Button.selected = NO;
        self.m15Button.selected = NO;
        self.m30Button.selected = NO;
        self.h1Button.selected = NO;
        self.h4Button.selected = NO;
        self.w1Button.selected = NO;
        self.mn1Button.selected = NO;

    }else if ([self.buttonString isEqualToString:@"w1"]){
        
        self.w1Button.selected = YES;
        
        self.m1Button.selected = NO;
        self.m5Button.selected = NO;
        self.m15Button.selected = NO;
        self.m30Button.selected = NO;
        self.h1Button.selected = NO;
        self.h4Button.selected = NO;
        self.d1Button.selected = NO;
        self.mn1Button.selected = NO;
        
    }else{
        
        self.mn1Button.selected = YES;
        
        self.m1Button.selected = NO;
        self.m5Button.selected = NO;
        self.m15Button.selected = NO;
        self.m30Button.selected = NO;
        self.h1Button.selected = NO;
        self.h4Button.selected = NO;
        self.d1Button.selected = NO;
        self.w1Button.selected = NO;
    }
    
}


- (void)UesrClicked:(UIButton *)button{
    
    [self.nowPriceLabel removeFromSuperview];
    [self.higestLabel removeFromSuperview];
    [self.higestValueLabel removeFromSuperview];
    [self.lowestLabel removeFromSuperview];
    [self.lowestValueLabel removeFromSuperview];
    [self.yestdayLabel removeFromSuperview];
    [self.yestdayValueLabel removeFromSuperview];
    [self.todayLabel removeFromSuperview];
    [self.todayValueLabel removeFromSuperview];
    
    if (button == self.m1Button) {
        
        self.m1Button.selected = YES;
        
        self.m5Button.selected = NO;
        self.m15Button.selected = NO;
        self.m30Button.selected = NO;
        self.h1Button.selected = NO;
        self.h4Button.selected = NO;
        self.d1Button.selected = NO;
        self.w1Button.selected = NO;
        self.mn1Button.selected = NO;
        
        self.buttonString = @"m1";
        
        [self loadKlineViewData];
        
    }else if (button == self.m5Button){
        
        self.m5Button.selected = YES;
        
        self.m1Button.selected = NO;
        self.m15Button.selected = NO;
        self.m30Button.selected = NO;
        self.h1Button.selected = NO;
        self.h4Button.selected = NO;
        self.d1Button.selected = NO;
        self.w1Button.selected = NO;
        self.mn1Button.selected = NO;
        
        self.buttonString = @"m5";
        
        [self loadKlineViewData];
        
    }else if (button == self.m15Button){
        
        self.m15Button.selected = YES;
        
        self.m1Button.selected = NO;
        self.m5Button.selected = NO;
        self.m30Button.selected = NO;
        self.h1Button.selected = NO;
        self.h4Button.selected = NO;
        self.d1Button.selected = NO;
        self.w1Button.selected = NO;
        self.mn1Button.selected = NO;
        
        self.buttonString = @"m15";
        
        [self loadKlineViewData];
        
    }else if (button == self.m30Button){
        
        self.m30Button.selected = YES;
        
        self.m1Button.selected = NO;
        self.m5Button.selected = NO;
        self.m15Button.selected = NO;
        self.h1Button.selected = NO;
        self.h4Button.selected = NO;
        self.d1Button.selected = NO;
        self.w1Button.selected = NO;
        self.mn1Button.selected = NO;
        
        self.buttonString = @"m30";
        
        [self loadKlineViewData];
        
    }else if (button == self.h1Button){
        
        self.h1Button.selected = YES;
        
        self.m1Button.selected = NO;
        self.m5Button.selected = NO;
        self.m15Button.selected = NO;
        self.m30Button.selected = NO;
        self.h4Button.selected = NO;
        self.d1Button.selected = NO;
        self.w1Button.selected = NO;
        self.mn1Button.selected = NO;
        
        self.buttonString = @"h1";
        
        [self loadKlineViewData];
        
    }else if (button == self.h4Button){
        
        self.h4Button.selected = YES;
        
        self.m1Button.selected = NO;
        self.m5Button.selected = NO;
        self.m15Button.selected = NO;
        self.m30Button.selected = NO;
        self.h1Button.selected = NO;
        self.d1Button.selected = NO;
        self.w1Button.selected = NO;
        self.mn1Button.selected = NO;
        
        self.buttonString = @"h4";
//        self.buttonString = @"h1";
        
        [self loadKlineViewData];
        
    }else if (button == self.d1Button){
        
        self.d1Button.selected = YES;
        
        self.m1Button.selected = NO;
        self.m5Button.selected = NO;
        self.m15Button.selected = NO;
        self.m30Button.selected = NO;
        self.h1Button.selected = NO;
        self.h4Button.selected = NO;
        self.w1Button.selected = NO;
        self.mn1Button.selected = NO;
        
        self.buttonString = @"d1";
//        self.buttonString = @"h1";
        
        [self loadKlineViewData];
        
    }else if (button == self.w1Button){
        
        self.w1Button.selected = YES;
        
        self.m1Button.selected = NO;
        self.m5Button.selected = NO;
        self.m15Button.selected = NO;
        self.m30Button.selected = NO;
        self.h1Button.selected = NO;
        self.h4Button.selected = NO;
        self.d1Button.selected = NO;
        self.mn1Button.selected = NO;
        
        self.buttonString = @"w1";
//        self.buttonString = @"h1";
        
        [self loadKlineViewData];
        
    }else{
        
        self.mn1Button.selected = YES;
        
        self.m1Button.selected = NO;
        self.m5Button.selected = NO;
        self.m15Button.selected = NO;
        self.m30Button.selected = NO;
        self.h1Button.selected = NO;
        self.h4Button.selected = NO;
        self.d1Button.selected = NO;
        self.w1Button.selected = NO;
        
        self.buttonString = @"mn1";
//        self.buttonString = @"h1";
        
        [self loadKlineViewData];
    }
    
    
}


-(void)chartValueSelected:(YKViewBase2 *)chartView entry:(id)entry entryIndex:(NSInteger)entryIndex
{
    
}

- (void)chartValueNothingSelected:(YKViewBase2 *)chartView
{
    
}

- (void)chartKlineScrollLeft:(YKViewBase2 *)chartView
{
    
}

- (void)setAccessibilityNavigationStyle:(UIAccessibilityNavigationStyle)accessibilityNavigationStyle {
    
}


- (void)loadData{
    
    _webSocketNumber.delegate = nil;
    [_webSocketNumber close];
    
    _webSocketNumber = [[SRWebSocket alloc] initWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"ws://103.20.249.35:9506"]]];
    
    //    NSOperationQueue * que = [NSOperationQueue new];
    _webSocketNumber.delegate = self;
    //    [_webSocketNumber setDelegateDispatchQueue:queue];
    //    [_webSocketNumber setDelegateOperationQueue:[NSOperationQueue mainQueue]];
    [_webSocketNumber open];   
    
}


- (void)webSocketDidOpen:(SRWebSocket *)webSocket;
{
    NSLog(@"Websocket Connected");
    
}

- (void)webSocket:(SRWebSocket *)webSocket didFailWithError:(NSError *)error;
{
    NSLog(@":( Websocket Failed With Error %@", error);
    
    _webSocketNumber = nil;
}


- (void)webSocket:(SRWebSocket *)webSocket didReceiveMessage:(id)message;
{
    
    
    NSData *jsonData = [message dataUsingEncoding:NSUTF8StringEncoding];
    NSError *err;
    NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData
                                                        options:NSJSONReadingMutableContainers
                                                          error:&err];
    
    NSArray * array = dic[@"quote"];
    
//    NSLog(@"==%@",array);
    
    for (NSDictionary * productInfoDict in array) {
        
        NSString * name = [NSString stringWithFormat:@"%@",productInfoDict[@"symbol"]];
        
        BOOL isFivebool = [self.fiveArray containsObject:name];
        BOOL isThreebool = [self.threeArray containsObject:name];
        BOOL isTwobool = [self.twoArray containsObject:name];
        
        if ([self.nameString isEqualToString:name]) {
            
            float high = [productInfoDict[@"high"] floatValue];
            float low = [productInfoDict[@"low"] floatValue];
            float bid = [productInfoDict[@"bid"] floatValue];
            
            if (isFivebool) {
                
                self.higestValueLabel.text = [NSString stringWithFormat:@"%.5f",high];
                self.lowestValueLabel.text = [NSString stringWithFormat:@"%.5f",low];
                self.nowPriceLabel.text = [NSString stringWithFormat:@"%.5f",bid];
                self.klineView.nowPrice = bid;
            }
            
            if (isThreebool) {
                
                self.higestValueLabel.text = [NSString stringWithFormat:@"%.3f",high];
                self.lowestValueLabel.text = [NSString stringWithFormat:@"%.3f",low];
                self.nowPriceLabel.text = [NSString stringWithFormat:@"%.3f",bid];
                self.klineView.nowPrice = bid;
            }
            
            if (isTwobool) {
                
                self.higestValueLabel.text = [NSString stringWithFormat:@"%.2f",high];
                self.lowestValueLabel.text = [NSString stringWithFormat:@"%.2f",low];
                self.nowPriceLabel.text = [NSString stringWithFormat:@"%.2f",bid];
                self.klineView.nowPrice = bid;
            }
        }
    }
    
}


- (void)webSocket:(SRWebSocket *)webSocket didCloseWithCode:(NSInteger)code reason:(NSString *)reason wasClean:(BOOL)wasClean;
{
    NSLog(@"WebSocket closed");
    _webSocketNumber = nil;
}

- (void)webSocket:(SRWebSocket *)webSocket didReceivePong:(NSData *)pongPayload;
{
    NSLog(@"Websocket received pong");
}


- (NSString*)weekdayStringFromDate:(NSDate*)inputDate {
    
    NSArray *weekdays = [NSArray arrayWithObjects: [NSNull null], @"Sunday", @"周一", @"周二", @"周三", @"周四", @"周五", @"周六", nil];
    
    NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
    
    NSTimeZone *timeZone = [[NSTimeZone alloc] initWithName:@"Asia/Shanghai"];
    
    [calendar setTimeZone: timeZone];
    
    NSCalendarUnit calendarUnit = NSCalendarUnitWeekday;
    
    NSDateComponents *theComponents = [calendar components:calendarUnit fromDate:inputDate];
    
    return [weekdays objectAtIndex:theComponents.weekday];
    
}

- (UIInterfaceOrientationMask) supportedInterfaceOrientations {
//     return UIInterfaceOrientationMaskAll;
    return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}

- (BOOL)shouldAutorotate {
    
    return YES;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationLandscapeLeft;
}

- (void)viewDidDisappear:(BOOL)animated{
    
    [_webSocketNumber close];
    
}


//- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
//    
//    
//    
////        NSLog(@"max==%f",self.klineView.maxPrice);
////        NSLog(@"min==%f",self.klineView.minPrice);
//    
//}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
